package com.ymatou.iapi.godfreightmgr.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godfreightmgr.parameter.CreateCollectionGoodsAddressBean;
import com.ymatou.iapi.godfreightmgr.service.CreateCollectionGoodsAddressCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godfreight.CollectiongoodsAddress;
import com.ymttest.database.sqlwapper.godfreight.CollectionGoodsWapper;
/**
*添加自提点
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CreateCollectionGoodsAddress{
	private static CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean;
	private static CreateCollectionGoodsAddressCall createcollectiongoodsaddressCall;
	com.ymttest.database.sqlwapper.godfreight.CollectionGoodsWapper CollectionGoodsWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("添加自提点");
	}

	@Before
	public void caseUp() {
		createcollectiongoodsaddressBean=new CreateCollectionGoodsAddressBean();
		createcollectiongoodsaddressCall=new CreateCollectionGoodsAddressCall();
		CollectionGoodsWapper=new CollectionGoodsWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(createcollectiongoodsaddressCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void verify(int addressid, CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean2) {
		CollectiongoodsAddress ca = CollectionGoodsWapper.selectCollectiongoodsAddress(addressid, createcollectiongoodsaddressBean2.getSellerId()).get(0);
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAddressName(), ca.getAddressName(), "验证AddressName");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAddressPic(), ca.getAddressPic(), "验证AddressPic");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAddressType(), ca.getAddressType(), "验证AddressType");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAreaCode(), ca.getAreaCode(), "验证AreaCode");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getBaseAddress()==null?"":createcollectiongoodsaddressBean2.getBaseAddress(), ca.getBaseAddress(), "验证BaseAddress");
		Logger.verifyNotNull( ca.getCreateTime(), "验证CreateTime");
		Logger.verifyEquals(false, ca.getDeleted(), "验证Deleted");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getDetailAddress(), ca.getDetailAddress(), "验证DetailAddress");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getMobile(), ca.getMobile(), "验证Mobile");
		Logger.verifyNotNull( ca.getUpdateTime(), "验证CreateTime");
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_001() {
		Logger.start(true,"添加自提点成功");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			createcollectiongoodsaddressBean.setSellerId(mchId_channl);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("200", createcollectiongoodsaddressCall.getString("code"), "验证code");
			verify(createcollectiongoodsaddressCall.getJsonObject().get("data").getAsJsonObject().get("addressId").getAsInt(),createcollectiongoodsaddressBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_002() {
		Logger.start(true,"不输入sellerid失败");
		try {
//			createcollectiongoodsaddressBean.setSellerId(mchId_channl);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_003() {
		Logger.start(true,"不输入addressName失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
//			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_004() {
		Logger.start(true,"不输入addressPic失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
//			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_005() {
		Logger.start(true,"不输入addressType失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
//			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_006() {
		Logger.start(true,"不输baseAddress成功");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			createcollectiongoodsaddressBean.setSellerId(mchId_channl);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(2);
			createcollectiongoodsaddressBean.setAreaCode("021");
//			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("200", createcollectiongoodsaddressCall.getString("code"), "验证code");
			verify(createcollectiongoodsaddressCall.getJsonObject().get("data").getAsJsonObject().get("addressId").getAsInt(),createcollectiongoodsaddressBean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_007() {
		Logger.start(true,"不输入detailAddress失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
//			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_008() {
		Logger.start(true,"不输入areaCode失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
//			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_009() {
		Logger.start(true,"不输入mobile失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
//			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_010() {
		Logger.start(true,"输入addressName超长失败");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			createcollectiongoodsaddressBean.setSellerId(mchId_channl);
			String name="";
			for (int i = 0; i < 50; i++) {
				name+="自提点AutoTest";
			}
			createcollectiongoodsaddressBean.setAddressName(name);
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_011() {
		Logger.start(true,"输入detailAddress超长失败");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			createcollectiongoodsaddressBean.setSellerId(mchId_channl);
			String name="";
			for (int i = 0; i < 50; i++) {
				name+="自提点AutoTest";
			}
			createcollectiongoodsaddressBean.setAddressName("autoAddress");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress(name);
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("500", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_012() {
		Logger.start(true,"输入错误的addressType失败");
		try {
			createcollectiongoodsaddressBean.setSellerId(1);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(3);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateCollectionGoodsAddress_013() {
		Logger.start(true,"自提点唯一");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			createcollectiongoodsaddressBean.setSellerId(mchId_channl);
			createcollectiongoodsaddressBean.setAddressName("自提点AutoTest");
			createcollectiongoodsaddressBean.setAddressPic("https://www.shop2cn.com/s1/shop/static/version2/icon1.png");
			createcollectiongoodsaddressBean.setAddressType(1);
			createcollectiongoodsaddressBean.setAreaCode("021");
			createcollectiongoodsaddressBean.setBaseAddress("境外");
			createcollectiongoodsaddressBean.setDetailAddress("2201 Wisconsin Avenue, N.W., Suite 110, Washington, DC 20007");
			createcollectiongoodsaddressBean.setMobile("001-202-4952216");
			createcollectiongoodsaddressCall.setData(createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("200", createcollectiongoodsaddressCall.getString("code"), "验证code");
			verify(createcollectiongoodsaddressCall.getJsonObject().get("data").getAsJsonObject().get("addressId").getAsInt(),createcollectiongoodsaddressBean);
			createcollectiongoodsaddressCall.callService();			
			Logger.verifyEquals("400", createcollectiongoodsaddressCall.getString("code"), "验证code");
			//已存在相同自提点
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}